package com.amazon.ags.client.achievements;

import android.content.Context;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.widget.RemoteViews;
import com.amazon.ags.api.ErrorCode;
import com.amazon.ags.api.RequestResponse;
import com.amazon.ags.client.BaseReplyMessengerFactory;
import com.amazon.ags.client.RequestResponseImp;
import com.amazon.ags.overlay.PopUpManager;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class AchievementsReplyMessengerFactory<T extends RequestResponse> extends BaseReplyMessengerFactory<T>
{
  private static final String FEATURE_NAME = "AC";
  private static final String TAG = "AC_" + AchievementsReplyMessengerFactory.class.getSimpleName();

  public AchievementsReplyMessengerFactory(Context paramContext)
  {
    super(paramContext);
  }

  protected final T processMessage(Message paramMessage)
  {
    Bundle localBundle = paramMessage.getData();
    int i = paramMessage.arg1;
    Log.d(TAG, "Processing incoming service response message of type: " + paramMessage.what + " and responseCode: " + i);
    switch (paramMessage.what)
    {
    case 18:
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
    case 24:
    case 25:
    default:
      Log.e(TAG, "Illegal value received for request type parameter: " + paramMessage.what);
      throw new IllegalArgumentException("Received an invalid value for request type parameter");
    case 17:
      if (i != 17)
      {
        int i1 = paramMessage.arg2;
        Log.d(TAG, "The service request was a failure with code " + i1 + ", constructing failure response");
        return new GetAchievementsResponseImp(i1, ErrorCode.fromServiceResponseCode(i1));
      }
      return unbundleRequestAchievementsResponse(localBundle, i);
    case 12:
      if (i != 17)
      {
        int n = paramMessage.arg2;
        Log.d(TAG, "The service request was a failure with code " + n + ", constructing failure response");
        return new GetAchievementResponseImp(n, ErrorCode.fromServiceResponseCode(n));
      }
      return unbundleRequestAchievementResponse(localBundle, i);
    case 13:
      if (i != 17)
      {
        int m = paramMessage.arg2;
        Log.d(TAG, "The service request was a failure with code " + m + ", constructing failure response");
        return new UpdateProgressResponseImp(m, ErrorCode.fromServiceResponseCode(m));
      }
      return unbundleUpdateProgressResponse(localBundle, i);
    case 16:
      if (i != 17)
      {
        int k = paramMessage.arg2;
        Log.d(TAG, "The service request was a failure with code " + k + ", constructing failure response");
        return new LoadIconResponseImp(k, ErrorCode.fromServiceResponseCode(k));
      }
      return unbundleLoadIconResponse(localBundle, i);
    case 14:
    case 15:
    case 26:
    }
    if (i != 17)
    {
      int j = paramMessage.arg2;
      Log.d(TAG, "The service request was a failure with code " + j + ", constructing failure response");
      return new RequestResponseImp(j, ErrorCode.fromServiceResponseCode(j));
    }
    return unbundleRequestResponse(localBundle, i);
  }

  public final T unbundleLoadIconResponse(Bundle paramBundle, int paramInt)
  {
    Log.d(TAG, "Entering unbundleLoadIconResponse...");
    byte[] arrayOfByte = paramBundle.getByteArray("ACHIEVEMENT_ICON_IMAGE");
    Log.d(TAG, "icon byte array in bundle: " + arrayOfByte);
    return new LoadIconResponseImp(arrayOfByte, paramInt);
  }

  public final T unbundleRequestAchievementResponse(Bundle paramBundle, int paramInt)
  {
    String str1 = paramBundle.getString("ACHIEVEMENT_ID");
    String str2 = paramBundle.getString("ACHIEVEMENT_TITLE");
    String str3 = paramBundle.getString("ACHIEVEMENT_DESCRIPTION");
    int i = paramBundle.getInt("ACHIEVEMENT_POINTS");
    boolean bool1 = paramBundle.getBoolean("ACHIEVEMENT_HIDDEN");
    boolean bool2 = paramBundle.getBoolean("ACHIEVEMENT_UNLOCKED");
    float f = paramBundle.getFloat("ACHIEVEMENT_UPDATE_PERCENT");
    int j = paramBundle.getInt("ACHIEVEMENT_POSITION");
    long l = paramBundle.getLong("ACHIEVEMENT_DATE_UNLOCKED", 0L);
    if ((!bool2) || (l == 0L));
    for (Date localDate = null; ; localDate = new Date(l))
      return new GetAchievementResponseImp(new AchievementImpl(str1, str2, str3, i, bool1, bool2, f, j, localDate), paramInt);
  }

  public final T unbundleRequestAchievementsResponse(Bundle paramBundle, int paramInt)
  {
    String[] arrayOfString1 = paramBundle.getStringArray("ACHIEVEMENT_ID");
    String[] arrayOfString2 = paramBundle.getStringArray("ACHIEVEMENT_TITLE");
    String[] arrayOfString3 = paramBundle.getStringArray("ACHIEVEMENT_DESCRIPTION");
    int[] arrayOfInt1 = paramBundle.getIntArray("ACHIEVEMENT_POINTS");
    boolean[] arrayOfBoolean1 = paramBundle.getBooleanArray("ACHIEVEMENT_HIDDEN");
    boolean[] arrayOfBoolean2 = paramBundle.getBooleanArray("ACHIEVEMENT_UNLOCKED");
    float[] arrayOfFloat = paramBundle.getFloatArray("ACHIEVEMENT_UPDATE_PERCENT");
    int[] arrayOfInt2 = paramBundle.getIntArray("ACHIEVEMENT_POSITION");
    long[] arrayOfLong = paramBundle.getLongArray("ACHIEVEMENT_DATE_UNLOCKED");
    ArrayList localArrayList = new ArrayList(arrayOfString1.length);
    int i = 0;
    if (i < arrayOfString1.length)
    {
      if ((arrayOfBoolean2[i] == 0) || (arrayOfLong == null));
      for (Date localDate = null; ; localDate = new Date(arrayOfLong[i]))
      {
        localArrayList.add(new AchievementImpl(arrayOfString1[i], arrayOfString2[i], arrayOfString3[i], arrayOfInt1[i], arrayOfBoolean1[i], arrayOfBoolean2[i], arrayOfFloat[i], arrayOfInt2[i], localDate));
        i++;
        break;
      }
    }
    return new GetAchievementsResponseImp(localArrayList, paramInt);
  }

  public final T unbundleRequestResponse(Bundle paramBundle, int paramInt)
  {
    return new RequestResponseImp(paramInt, ErrorCode.NONE);
  }

  public final T unbundleUpdateProgressResponse(Bundle paramBundle, int paramInt)
  {
    UpdateProgressResponseImp localUpdateProgressResponseImp = new UpdateProgressResponseImp(paramBundle.getBoolean("ACHIEVEMENT_NEWLY_UNLOCKED"), paramInt);
    int i = paramBundle.getInt("ACHIEVEMENT_OVERLAY_CALLBACK");
    RemoteViews localRemoteViews = (RemoteViews)paramBundle.getParcelable("ACHIEVEMENT_POP_UP_LAYOUT");
    if (localRemoteViews != null)
      this.popUpManager.executePopUp(localRemoteViews, i);
    return localUpdateProgressResponseImp;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.amazon.ags.client.achievements.AchievementsReplyMessengerFactory
 * JD-Core Version:    0.6.2
 */